﻿USE [XUAT_NHAP TON]
GO

-- Tạo bảng Sinh viên
CREATE TABLE SINHVIEN
(
	MASV VARCHAR(15) PRIMARY KEY NOT NULL,
	TENSV NVARCHAR(50),
	GIOITINH NVARCHAR(10),
	NGAYSINH DATETIME,
	QUEQUAN NVARCHAR(100),
	EMAIL VARCHAR(30),
	SDT VARCHAR(20)
)
GO

-- =============================================
-- Author:		<THUANVV>
-- Create date: <02/12/2015>
-- Description:	<Thêm thông tin SINHVIEN>
-- =============================================
CREATE PROCEDURE SINHVIEN_Insert 
	@MASV varchar(15),
	@TENSV nvarchar(50),
	@GIOITINH nvarchar(10),
	@NGAYSINH datetime,
	@QUEQUAN nvarchar(100),
	@EMAIL varchar(30),
	@SDT varchar(20)
AS
BEGIN
	INSERT INTO SINHVIEN([MASV],[TENSV],[GIOITINH],[NGAYSINH],[QUEQUAN],[EMAIL],[SDT])
	VALUES (@MASV,@TENSV,@GIOITINH,@NGAYSINH,@QUEQUAN,@EMAIL,@SDT)
END
GO

-- =============================================
-- Author:		<THUANVV>
-- Create date: <02/12/2015>
-- Description:	<Sửa thông tin SINHVIEN>
-- =============================================
CREATE PROCEDURE SINHVIEN_Update 
	@MASV varchar(15),
	@TENSV nvarchar(50),
	@GIOITINH nvarchar(10),
	@NGAYSINH datetime,
	@QUEQUAN nvarchar(100),
	@EMAIL varchar(30),
	@SDT varchar(20)
AS
BEGIN
	UPDATE SINHVIEN
	SET TENSV=@TENSV,GIOITINH=@GIOITINH,NGAYSINH=@NGAYSINH,QUEQUAN=@QUEQUAN,EMAIL=@EMAIL,SDT=@SDT
	WHERE MASV=@MASV
		
END
GO

-- =============================================
-- Author:		<THUANVV>
-- Create date: <02/12/2015>
-- Description:	<Xóa thông tin SINHVIEN>
-- =============================================
CREATE PROCEDURE SINHVIEN_Delete 
	@MASV varchar(15)
AS
BEGIN
	DELETE SINHVIEN
	WHERE MASV=@MASV
END
GO

-- =============================================
-- Author:		<THUANVV>
-- Create date: <02/12/2015>
-- Description:	<Lấy toàn bộ thông tin SINHVIEN>
-- =============================================
CREATE PROCEDURE SINHVIEN_GetAll
AS
BEGIN
	SELECT * FROM SINHVIEN
END
GO

-- =============================================
-- Author:		<THUANVV>
-- Create date: <02/12/2015>
-- Description:	<Lấy thông tin SINHVIEN>
-- =============================================
CREATE PROCEDURE SINHVIEN_GetOne
	@MASV varchar(15)
AS
BEGIN
	SELECT * FROM SINHVIEN
	WHERE MASV=@MASV
END
GO